using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using Planisoft.Entities;



namespace Planisoft.DAO.Mapping
{
    public class ValoresParametroMap : EntityTypeConfiguration<ValoresParametro>
    {
        public ValoresParametroMap()
        {
            // Primary Key
            this.HasKey(t => new { t.IdParametro, t.Mes, t.Anio, t.Trimestre, t.Valor });

            // Properties
            this.Property(t => t.IdParametro)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Mes)
                .IsRequired()
                .HasMaxLength(2);

            this.Property(t => t.Anio)
                .IsRequired()
                .HasMaxLength(4);

            this.Property(t => t.Trimestre)
                .IsRequired()
                .HasMaxLength(1);

            this.Property(t => t.Valor)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("ValoresParametros");
            this.Property(t => t.IdParametro).HasColumnName("IdParametro");
            this.Property(t => t.Mes).HasColumnName("Mes");
            this.Property(t => t.Anio).HasColumnName("Anio");
            this.Property(t => t.Trimestre).HasColumnName("Trimestre");
            this.Property(t => t.Valor).HasColumnName("Valor");

            // Relationships
            this.HasRequired(t => t.Parametro)
                .WithMany(t => t.ValoresParametros)
                .HasForeignKey(d => d.IdParametro);

        }
    }
}
